# 导包
import requests
from api.ihrm_longin_aip import Ihrm_LonginAPI
from common.pymy_tool import DBUtil


class ihrm_deleteAPI:
    @classmethod
    def ihrm_delete(cls,id):
        # 准备ihrm登录请求的请求体，获取到令牌
        url_longin_body = {"mobile": "13800000002", "password": "123456"}
        # 调用ihrm登录接口层的登录请求类的方法，参数中传递请全体，获取响应数据
        res = Ihrm_LonginAPI.ihrm_longin(url_longin_body)
        # 从响应数据中获取到的结果，拼成一个完整的令牌
        token = "Bearer " + res.json()["data"]

        # 准备删除员工接口的请求体
        url_delete_hang = f"http://ihrm-test.itheima.net/api/sys/user/{id}"
        url_delete_head = {"Authorization": token}
        res_delete = requests.delete(url=url_delete_hang,headers=url_delete_head)

        return res_delete

